package com.atguigu.yygh.oss.controller;

import com.atguigu.yygh.common.R;
import com.atguigu.yygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author DongYu Zhou
 * @date 2022/7/2 18:30
 */
@Api(tags = "阿里云文件管理")
@RestController
@RequestMapping("/api/oss/file")
public class FileUploadController {
    @Autowired
    private FileService fileService;

    /**
     * 文件上传接口 返回ok
     * @param file
     * @return
     */
    @ApiOperation(value = "文件上传")
    @PostMapping("/upload")
    public R upload(@RequestParam("file")MultipartFile file){
       String url= fileService.upload(file);
        return R.ok().data("url",url);
    }
}
